package com.ikunikun.controller.user;

import com.ikunikun.dto.UserLoginDTO;
import com.ikunikun.result.Result;
import com.ikunikun.service.UserService;
import com.ikunikun.vo.UserLoginVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@Api(tags = "C端用户相关接口")
@RestController
@RequestMapping("/user/user")
public class UserController {

	@Resource
	private UserService userService;

	/**
	 * 微信登录
	 * @param userLoginDTO
	 * @return
	 */
	@ApiOperation("微信登录")
	@PostMapping("/login")
	public Result<UserLoginVO> login(@RequestBody UserLoginDTO userLoginDTO){
		log.info("用户登录,Code: {}", userLoginDTO.getCode());
		UserLoginVO userLoginVO = userService.login(userLoginDTO);
		return Result.success(userLoginVO);
	}
}
